14.3 Creating a mapping file

MyID provides example mapping files for the four standard notifications; see section 14.2, Standard REST notifications for details of these files and their output.

You can use these files as a basis for your own files, or create your own files from scratch. Do not edit the content of the provided files, as they may be overwritten if you update or upgrade your system.

Mapping files are stored in the following folder by default:

C:\Program Files\Intercede\MyID\Components\ExternalSystemMappings\

Any XML file you place in this folder is available for selection from the Mapping File drop-down list in the External Systems workflow.

14.3.1 Notification

The <Notification> node is the root node of the XML file. Each mapping file has one and only one <Notification> node, which contains the <DataSources>, <Endpoint>, and <Body> nodes.

14.3.2 DataSources

The <DataSources> node contains one or more <DataSource> nodes, each of which specifies the name of a table or view in the MyID database. You must specify which field in the table or view you are matching against the device, person, or job ID for the notification. You can also specify an optional WHERE clause to restrict the data further; MyID does not support multiple records in a notification, so if the data source and where clause result in multiple records, the first record is used.

Each <DataSource> node has the following format:

Copy
<DataSource ID="id" View="view or table name" Lookup="identifier" FieldName="field" />

where:

For example:

Copy
<DataSources>
  <DataSource ID="People" View="vPeopleUserAccounts" Lookup="PersonID" />
  <DataSource ID="Devices" View="vDevices" Lookup="DeviceID" />
</DataSources>

This creates two data sources:

You can now access any field in the vPeopleUserAccounts view for the person, or the vDevices view for that device; for example, to include the device GUID in the endpoint:

Copy
<Endpoint Verb="POST" URL="/devices/{Devices.ObjectID}/deviceCancelled" />

or, to include the person's email address in the body payload:

Copy
<Source Field="Email" Retrieval="People" />

14.3.2.1 Where clauses

Optionally, you can add one or more <Where> nodes inside the <DataSource> node. This node has the following format:

Copy
<Where FieldName="fieldname" FieldValue="fieldvalue" Operation="operation" Conjunction="[and|or]" />

where:

For example:

Copy
<DataSource ID="PivAuthCert" View="vCertInstances" Lookup="DeviceID">
  <Where>
    <FieldName>ContainerName</FieldName>
    <FieldValue>5FC105</FieldValue>
    <Operation>=</Operation>
  </Where>
</DataSource>

This returns the details from the vCertInstances view for the device that is the subject of the notification; as there are multiple certificates for a single device, the <where> node restricts the returned data to the certificate where the container name matches the name for the PIV Authentication certificate.

14.3.3 Endpoint

The <Endpoint> node specifies the REST web service endpoint to which MyID sends the notification. The format is:

Copy
<Endpoint Verb="verb" URL="url"/>

where:

For example:

Copy
<Endpoint Verb="POST" URL="/devices/{Devices.ObjectID}/deviceCancelled" />

If the API Location field in the external system is:

https://myserver/Notify

and the device GUID (as obtained from the ObjectID field in the Devices data source, which refers to the vDevices view in the database) is:

79036d80-8322-404f-b146-f37af6b016b4

then MyID sends a POST request to:

https://myserver/Notify/devices/79036d80-8322-404f-b146-f37af6b016b4/deviceCancelled

14.3.4 Body

The <Body> node specifies the data that is sent to the REST web service.

Within the <Body> node, you can include one or more <Property> nodes. Each <Property> node has a JPath attribute that specifies the location in the JSON output where the value is to be included, and a <Source> node that specifies the data to include in the JSON output for the specified JPath.

The format is:

Copy
<Property JPath="path">
  <Source
    Retrieval="datasource" 
    Field="fieldname" 
    EncodingFormat="format" 
    DataType="type" 
    Default="staticvalue" />
</Property>

where:

For example:

Copy
<Property JPath="device.validity.enabled">
  <Source EncodingFormat="Boolean" Field="Enabled" Retrieval="Devices" />
</Property>

This obtains the value for Enabled field in the Devices data source, which refers to the vDevices view in the database; this value is 0 or 1 in the database, but the EncodingFormat tells MyID to output it as true or false to the appropriate place in the JSON output; for example:

Copy

  "device": {
    "validity": {
      "enabled": true
    },
  }
}

14.3.4.1 Additional processing

Optionally, you can add a <Processor> node inside the <Source> node to carry out additional processing on the value obtained from the database. This node has the following format:

Copy
<Processor Type="type" P1="Param1" P2="Param2" />

where:

For example:

Copy
<Property JPath="device.fascn">
  <Source Field="SN3" Retrieval="Devices">
    <Processor Type="substring" P1="14" P2="6"/>
  </Source>
</Property>

This obtains the value for the SN3 field in the Devices data source, which refers to the vDevices view in the database, then obtains a 6-character section of this value starting at position 14 (based on zero-based indexing).

If the SN3 value is:

0011 - 0000 - 250018 - 1 - 1 - 0000000001 1 1234 4 - 28

the output is:

Copy
{
    "device": {
        "fascn": "250018"
        },
    }
}